﻿using System;

public class ClockEventArgs : EventArgs
{
    public string Message { get; }

    public ClockEventArgs(string message)
    {
        Message = message;
    }
}

public class AlarmClock
{
    public event EventHandler<ClockEventArgs> Tick;
    public event EventHandler<ClockEventArgs> Alarm;

    public void Run(int seconds)
    {
        Console.WriteLine("闹钟启动");
        for (int i = 0; i < seconds; i++)
        {
            Thread.Sleep(1000);
            OnTick(new ClockEventArgs($"第 {i + 1} 秒"));
            if ((i + 1) % 10 == 0) 
            {
                OnAlarm(new ClockEventArgs($"已经过 {i + 1} 秒，闹钟响铃！"));
            }
        }

        Console.WriteLine("闹钟结束");
    }

    protected virtual void OnTick(ClockEventArgs e)
    {
        Tick?.Invoke(this, e);
    }

    protected virtual void OnAlarm(ClockEventArgs e)
    {
        Alarm?.Invoke(this, e);
    }
}

class Program
{
    static void Main(string[] args)
    {
        AlarmClock alarmClock = new AlarmClock();
        alarmClock.Tick += (sender, e) => Console.WriteLine($"嘀嗒声：{e.Message}");
        alarmClock.Alarm += (sender, e) => Console.WriteLine($"闹钟：{e.Message}");
        alarmClock.Run(30);
        Console.ReadLine(); // 等待用户按下回车键退出
    }
}
